﻿Namespace ORM
    Public Class Person_ORM
        'Public Function GetOne(ByVal idPersona As Integer) As WebCredit.EntityClass.Person_Entity

        'End Function

        Public Function GetAll() As System.Collections.Generic.List(Of EntityClass.Person_Entity)
            Dim oDatos As New WebCredit.Datos
            Dim dr As SqlClient.SqlDataReader
            Dim c As New System.Collections.Generic.List(Of EntityClass.Person_Entity)

            dr = oDatos.EjecutarSP_Col("spPersonaGetAll")
            Do While dr.Read
                Dim oPerson As New WebCredit.EntityClass.Person_Entity

                oPerson.Apellido = dr("Apellido")
                oPerson.Nombre = dr("Nombre")
                oPerson.id_Persona = dr("Id_persona")

                c.Add(oPerson)
            Loop
            Return c
        End Function
        Public Function InsertOne(ByVal e As EntityClass.Person_Entity) As Integer
            Dim oDatos As New WebCredit.Datos
            Dim c As New Collection
            c.Add(e.id_Persona)
            c.Add(e.Tipo.id_Tipo)
            c.Add(e.Localidad.id_Localidad)
            c.Add(e.Impuesto.id_Impuesto)
            c.Add(e.Nombre)
            c.Add(e.Apellido)
            c.Add(e.RazonSocial)
            c.Add(e.Domicilio)
            c.Add(e.CodigoPostal)
            c.Add(e.Tel)
            c.Add(e.Cel)
            c.Add(e.Email)
            c.Add(e.CUIT)
            c.Add(e.Sueldo)
            c.Add(e.LimiteCredito)
            'c.Add e.Movimientos 
            c.Add(e.Status)
            Dim ok As Integer = 0
            ok = oDatos.EjecutarSP_INT("spPersonaInsert", c)
            If ok < 0 Then
                'uppsss 
            End If
            c = Nothing
            oDatos = Nothing
            Return ok

        End Function
        'Public Function UpdateOne(ByVal e As EntityClass.Person_Entity)

        'End Function
        Public Function DeleteOne(ByVal idPerson As Integer) As Integer
            Dim oDatos As New WebCredit.Datos
            Dim c As New Collection
            c.Add(idPerson)

            Dim ok As Integer = 0
            ok = oDatos.EjecutarSP_INT("spPersonaDelByID", c)
            If ok < 0 Then
                'uppsss 
            End If
            c = Nothing
            oDatos = Nothing
            Return ok

        End Function
    End Class
End Namespace

